/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-25 22:54:13
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.bp.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Set;
import java.util.LinkedHashSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.EntityListeners;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;

import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_bp_accident")
@SQLDelete(sql = "update wwyt_bp_accident set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_bp_accident set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class BpAccident implements java.io.Serializable {

    //columns START
    @Id
    @GeneratedValue(strategy = IDENTITY)

    //ID
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    //编号
    @Column(name = "CODE", length = 10, nullable = false)
    private String code;

    //名称
    @Column(name = "NAME", length = 100, nullable = false)
    private String name;

    //发生时间
    @Column(name = "HAPPEN_TIME", nullable = false)
    private java.util.Date happenTime;

    //发生地点坐标
    @Column(name = "LOCATION_COORDS", length = 500, nullable = false)
    private String locationCoords;

    //发生地点名称
    @Column(name = "LOCATION_NAME", length = 300)
    private String locationName;

    //事故原因
    @Column(name = "REASON", nullable = false)
    private Long reason;

    //上报人
    @Column(name = "REPORTOR_ID", nullable = false)
    private Long reportorId;

    //上报时间
    @Column(name = "REPORT_TIME", nullable = false)
    private java.util.Date reportTime;

    //发生区域
    @Column(name = "RISK_DISTRICT_ID", nullable = false)
    private Long riskDistrictId;

    //附件ID
    @Column(name = "ATTACHMENT_ID")
    private Long attachmentId;

    //事故原因分析
    @Column(name = "REASON_ANALYSIS", length = 65535, nullable = false)
    private String reasonAnalysis;

    //事故描述
    @Column(name = "REASON_DESCRIPTION", length = 65535, nullable = false)
    private String reasonDescription;

    //状态
    @Column(name = "STATE")
    private Byte state;

    //事故等级
    @Column(name = "LEVEL")
    private Integer level;

    //整改责任人
    @Column(name = "CORRECTIVE_IN_CHARGE_USER_ID")
    private Long correctiveInChargeUserId;

    //责任人处理结果
    @Column(name = "IN_CHARGE_USER_PROCESS_RESULT", length = 500)
    private String inChargeUserProcessResult;

    //人员伤亡情况
    @Column(name = "CASUALTIES", length = 500)
    private String casualties;

    //火灾损失影响
    @Column(name = "LOSS_OF_FIRE", length = 65535)
    private String lossOfFire;

    //危化品泄露影响
    @Column(name = "HCH_REVEAL_CONSEQUENCE", length = 65535)
    private String hchRevealConsequence;

    //设备事故影响
    @Column(name = "FACILITY_ACCIDENT_CONSEQUENCE", length = 65535)
    private String facilityAccidentConsequence;

    //工艺事故影响
    @Column(name = "CRAFT_ACCIDENT_CONSEQUENCE", length = 65535)
    private String craftAccidentConsequence;

    //事故链
    @Column(name = "ACCIDENT_CHAIN_FILE_ID")
    private Long accidentChainFileId;

    //事故树分析表
    @Column(name = "ACCIDENT_TREE_ANALYSE_TABLE_FILE_ID")
    private Long accidentTreeAnalyseTableFileId;

    //最终调查报告
    @Column(name = "FINAL_REPORT_FILE_ID")
    private Long finalReportFileId;

    //创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    //创建时间
    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;

    //更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    //更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private java.util.Date updateTime;

    //删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    private String deleteFlag;

    //组织机构代码
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;

    //租户
    @Column(name = "TENENT_ID")
    private Long tenentId;

    //事故部门
    @Column(name = "DEPART_ID")
    private Long departId;

    //事故类别
    @Column(name = "accident_categories", length = 65535, nullable = false)
    private String accidentCategories;
    //建议完成期限
    @Column(name = "suggested_completion_period", length = 65535, nullable = false)
    private String suggestedCompletionPeriod;
    //审批意见
    @Column(name = "approval_opinion", length = 65535, nullable = false)
    private String approvalOpinion;
    //columns END

    @Column(name = "audit_state")
    private Integer auditState;

    public int hashCode() {
        return new HashCodeBuilder()
                .append(getId())
                .toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BpAccident == false) return false;
        if (this == obj) return true;
        BpAccident other = (BpAccident) obj;
        return new EqualsBuilder()
                .append(getId(), other.getId())
                .isEquals();
    }
}

